package com.rostami.tutorial.spring.main;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.rostami.tutorial.spring.collection.RestaurantCollection;
import com.rostami.tutorial.spring.diSetterMethod.RestaurantSetter;

public class TestSpring {
	
	public static void main(String [] args){
		try{
			@SuppressWarnings("resource")
			ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig.xml");
			
			HelloSpring helloSpring = (HelloSpring) context.getBean("helloSpringBean");
			helloSpring.greet();
			
			Restaurant restaurant = (Restaurant) context.getBean("restaurantBean");
			restaurant.prepareHotDrink();
			
			RestaurantSetter restaurantSetter = (RestaurantSetter) context.getBean("restaurantSetterBean");
			restaurantSetter.prepareHotDrink();
			
			RestaurantCollection restaurantCollection = (RestaurantCollection) context.getBean("restaurantCollectionBean");
			restaurantCollection.printWaitersInRestaurant();
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
